<template>
  <div>
    <el-form :model="form" :rules="rules" ref="form" label-width="80px">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="form.name" placeholder="请输入姓名"></el-input>
      </el-form-item>

      <el-form-item label="邮箱" prop="email">
        <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
      </el-form-item>

      <el-form-item label="电话" prop="phone">
        <el-input v-model="form.phone" placeholder="请输入电话"></el-input>
      </el-form-item>

      <el-form-item label="预约日期" prop="date">
        <el-date-picker v-model="form.date" type="date" placeholder="请选择日期"></el-date-picker>
      </el-form-item>

      <el-form-item label="预约时间" prop="time">
        <el-time-picker v-model="form.time" placeholder="请选择时间"></el-time-picker>
      </el-form-item>

      <el-form-item label="预约服务" prop="service">
        <el-select v-model="form.service" placeholder="请选择服务">
          <el-option label="服务1" value="服务1"></el-option>
          <el-option label="服务2" value="服务2"></el-option>
          <el-option label="服务3" value="服务3"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('form')">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

export default {
  name: 'HotelSystemAdminCc',

  data () {
    return {
      form: {
        name: '',
        email: '',
        phone: '',
        date: '',
        time: '',
        service: ''
      },
      rules: {
        name: [
          { required: true, message: '请填写姓名', trigger: 'blur' }
        ],
        email: [
          { required: true, message: '请填写邮箱', trigger: 'blur' },
          { type: 'email', message: '请输入正确的邮箱格式', trigger: ['blur', 'change'] }
        ],
        phone: [
          { required: true, message: '请填写电话', trigger: 'blur' }
        ],
        date: [
          { required: true, message: '请选择预约日期', trigger: 'change' }
        ],
        time: [
          { required: true, message: '请选择预约时间', trigger: 'change' }
        ],
        service: [
          { required: true, message: '请选择预约服务', trigger: 'change' }
        ]
      }

    }
  },
  methods: {
    submitForm () {
      this.$refs.form.validate(valid => {
        if (valid) {
          // 提交表单
          console.log(this.form)
        } else {
          console.log('表单验证失败')
          return false
        }
      })
    },
    resetForm () {
      this.$refs.form.resetFields()
    },
    handleSuccess (response, file, fileList) {
      console.log('上传成功')
    }
  }
}
</script>

<style lang="less" scoped>
.hotel-form {
  margin: 50px auto;
  width: 600px;
  padding: 30px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

.form-title {
  text-align: center;
}

.form {
  margin-top: 30px;
}

.el-form-item__label {
  font-weight: bold;
}

.el-form-item__content {
  margin-left: 120px;
  width: 20%;
}

.el-input__inner,
.el-select__input {
  border-radius: 5px;
}

.el-upload__tip {
  margin-left: 120px;
}

.el-button {
  margin-right: 20px;
}

.el-form-item:last-child {
  margin-bottom: 0;
}
</style>
